package com.it.service.impl;

import com.it.dao.BookDao;
import com.it.pojo.Book;
import com.it.service.BookService;
import com.it.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookDao bookDao;
    @Override
    public PageUtils<Book> queryByPage(Map<String, Object> params, PageUtils pageUtils) {
        List<Book> carList = bookDao.selectByPage(params);
        pageUtils.setData(carList);
        return pageUtils;
    }

    @Override
    public int queryTotal(Map<String, Object> params) {
        int total = bookDao.selectTotal(params);
        return total;
    }

    @Override
    public int save(Book book) {
        int row = bookDao.insert(book);
        return row;
    }

    @Override
    public int dropBatch(Integer[] ids) {
        int row = bookDao.deleteBatch(ids);
        return row;
    }

    @Override
    public int drop(Integer id) {
        int row = bookDao.delete(id);
        return row;
    }

    @Override
    public int modify(Book book) {
        int row = bookDao.update(book);
        return row;
    }

    @Override
    public Book queryById(Integer id) {
        Book book = bookDao.selectById(id);
        return book;
    }
}
